package com.maozai.maozaimall.order.vo;

import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

//订单确认页需要用的数据
public class OrderConfirmVo {

    //收获地址列表
    @Setter @Getter
    List<MemberAddressVo> address;

    //所有选中的购物项
    @Setter @Getter
    List<OrderItemVo> items;

    Integer count;
    public Integer getCount() {
        Integer sum = 0;
        if (items != null) {
            for (OrderItemVo item : items) {
                BigDecimal decimal = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
                sum += item.getCount();
            }
        }
        return sum;
    }

    //发票信息

    //优惠卷信息
    @Setter @Getter
    private Integer integration;
    @Setter @Getter
    Map<Long, Boolean> stocks;

    BigDecimal total; //订单总额

    public BigDecimal getTotal() {
        BigDecimal sum = new BigDecimal("0");
        if (items != null) {
            for (OrderItemVo item : items) {
                BigDecimal decimal = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
                sum = sum.add(decimal);
            }
        }
        return sum;
    }

    BigDecimal payPrice;// 应付的价格

    public BigDecimal getPayPrice() {
        return getTotal();
    }
    //防重令牌
    @Setter @Getter
    String orderToken;

}
